package cn.skywalks.common.utils;

import java.io.UnsupportedEncodingException;

/**
 * Created by lpeng on 2017/7/12.
 */
public class CharEncoding {

    public static final String ISO_8859_1 = "ISO-8859-1";

    public static final String US_ASCII = "US-ASCII";

    public static final String UTF_16 = "UTF-16";

    public static final String UTF_16BE = "UTF-16BE";

    public static final String UTF_16LE = "UTF-16LE";

    public static final String UTF_8 = "UTF-8";

    /**
     * 判断指定的字符集是否支持
     *
     * @param charSet
     * @return
     */
    public static boolean isSupported(String charSet){
        if (StringUtil.isEmpty(charSet)){
            return false;
        }
        try {
            byte[] bytes = new byte[0];
            new String(bytes, charSet);
        } catch (UnsupportedEncodingException e) {
            return false;
        }
        return true;
    }
}
